<template>
	<view>
		<view class="con_box">
			<view>头像</view>
			<view class="flex" style="display: flex;">
				<image @click="changeImg" class="img" :src="from.avatar"></image>
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view>
		<view class="con_box">
			<view>昵称</view>
			<view  class="flex">
				<!-- <view class="con_tiot">张华月</view> -->
				<input type="text" v-model="from.nickname" placeholder="请输入昵称" >
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view>
	<!-- 	<view class="con_box">
			<view>手机号</view>
			<view  class="flex">
				<view class="con_tiot">1237483883</view>
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view> -->
		<!-- <view class="con_box">
			<view>会员码</view>
			<view class="flex">
				<image class="img" src="../static/images/setting.png"></image>
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view> -->
		<view class="con_box">
			<view>真实信息</view>
			<view  class="flex">
				<!-- <view class="con_tiot">方启航</view> -->
				<input type="text" v-model="from.realname" placeholder="请输入真实姓名" >
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view>
		<view class="con_box">
			<view>身份证</view>
			<view  class="flex">
				<!-- <view class="con_tiot">3836484927274847</view> -->
					<input type="number" v-model="from.realnumber" placeholder="请输入身份证号" >
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view>
		<view class="con_box">
			<view>银行卡</view>
			<view  class="flex">
				<!-- <view class="con_tiot">未绑定</view> -->
					<input type="number" v-model="from.bank_card" placeholder="请输入银行卡号" >
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view>
		<!-- <view class="con_box">
			<view>微信自动提现</view>
			<view  class="flex">
				<view class="con_tiot">关闭</view>
				<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
			</view>
		</view> -->
		<button class="submitBtn" @click="submit()">提交</button>
	</view>
</template>

<script>
	import {getUserInfo,changeMobile} from '@/api/merchat.js'
	import {
		BASE_URL
	} from '@/env'
	export default {
		
		data() {
			return {
				page:1,
				lastPage:0,
				Datalist:[],
				statusText:"",
				from:{
					avatar:"",
					nickname:"",
					realname:"",
					realnumber:"",
					bank_card:"",
				}
				
			};
		},
		onLoad() {
				this.getData()
		},

		methods:{
				getData(){
					getUserInfo(this.from).then(res=>{
						console.log(res)
						this.from = res.data
					})
				},
				changeImg(){
					let vm =this
					uni.chooseImage({
						count: 1, 
						success: function(res) {
							uni.showLoading({
								title: '头像上传中',
							});
							uni.uploadFile({
								url: BASE_URL + '/api/common/upload',
								filePath: res.tempFilePaths[0],
								name: 'file',
								header: {
									// #ifdef MP
									"Content-Type": "multipart/form-data",
									// #endif
								},
								success: function(res) {
									console.log(res)
									vm.from.avatar = JSON.parse(res.data).data.url
									uni.hideLoading();
								},
								fail: function(err) {
									uni.hideLoading();
									
								}
							})
							
						}
					})	
				},
				submit(){
						
					// if(!this.info){
					// 	uni.showToast({
					// 		title:'请输入反馈意见内容！',
					// 		icon:'none'
					// 	})
					// 	return
					// }
					uni.showLoading({
						title:'提交中'
					})
					getUserInfo(this.from).then(res=>{
						uni.hideLoading()
						uni.showToast({
							title:'提交成功！',
							icon:'success'
						})
						this.$store.commit('userInfo',this.from)
						setTimeout(()=>{
						uni.switchTab({
							url:'/pages/index/user'
						})
						},1500)
					})
				}
		}
	}
</script>

<style lang="scss" scoped>
.con_box{
		width: 100%;
		height: 112rpx;
		background: #13114c;
		border-bottom:1px solid #E7E7E7;;
		padding: 40rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		color: #ffffff;
	}
	.img{
		width: 48rpx;
		height: 48rpx;
		margin-right: 20rpx;
		border-radius: 50%;
	}
	.flex{
		text-align: right;
		display: flex;
	}
	.con_tiot{
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
	}
	.submitBtn{
		    background: #4f83fd;
		    color: #fff;
		    width: 600rpx;
			margin-top: 20rpx;
	}
</style>
